﻿namespace DimensionsHelper.LanguageService.Syntax;

public abstract class BodiedDeclaration : Declaration
{
    private Block _body;

    internal BodiedDeclaration(SyntaxKinds kind, SyntaxToken declareKeywordToken, Identifier name,
        SyntaxNode? parent) :
        base(kind, declareKeywordToken, name, parent)
    {
        _body = Block.Default;
    }

    public Block Body => _body;


    public BodiedDeclaration Update(Block body)
    {
        SetChildField(ref _body, Block.IsEmptyOrDefault, body);
        return this;
    }


    public override void AcceptVisitor<T>(SyntaxNodeVisitor<T> visitor)
    {
        Accept(visitor, Body);
        base.AcceptVisitor(visitor);
    }
}